<template>
  <div id="myChart" :style="{width: '800px', height: '600px'}"></div>
</template>
<script>
import * as echarts from 'echarts';
import {meetingbing} from "@/api/project/meeting";
export default {
  name: "meetingpie",
  //参数
  data(){
    return{
      pName:[],//name值
      pValue:[]//value值
    }
  },
  mounted() {
    this.$nextTick(()=>{
      this.getList();
    })
  },
  created() {
  },
  methods:{
    getList() {
      meetingbing().then(res => {
        if (res.code == 200) {
          this.myEachars(res.data);
        }
      })
    },
    //饼图
    myEachars(datm){
      var datas = []
      for (let i = 0; i < datm.length; i++) {
        var item = {
          value: datm[i].value,
          name: datm[i].name,
        };
        datas.push(item);
      }
      console.log(datas);
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('myChart'));
      // 指定图表的配置项和数据
      var option = {
        legend: {
          top: 'bottom'
        },
        tooltip: {
          trigger: 'item'
        },
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        series: [
          {
            name: "会议统计图",
            type: 'pie',
            radius: [50, 250],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            data:datas
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    }
  }
}
</script>
